<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<s:url value="/dtree/dtree.css"/>" rel="stylesheet" type="text/css" />
<link href="<s:url value="/css/style.css"/>" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<s:url value="/js/jquery.js"/>"></script>
<script type="text/javascript" src="<s:url value="/js/common.js"/>"></script>
<script type="text/javascript" src="<s:url value="/js/jquery.validate.js"/>"></script>
<script type="text/javascript">
var rootUrl = '<s:url value="/" forceAddSchemeHostAndPort="true"/>';
rootUrl = rootUrl.substring(0, rootUrl.lastIndexOf('/') )+'/dtree/'; 
</script>
<script type="text/javascript" src="<s:url value="/dtree/dtree.js"/>"></script>
<script type="text/javascript">
function doSubmit(){
	if(window.confirm('Save modify?')) {
		// here is validate form .
		var ids = "";
				var form = document.getElementById("dTreeForm");
				for (var i=0; i<form.elements.length; i++) {
					var element = form.elements[i];
					if (element.name == "id" && element.type=='checkbox'){
						if( element.checked == true ){
							ids = ids + element.value + ",";
						}
					}
				}		
				//alert("ids = " + ids);
		$('#menu').val(ids);
		 $('#editForm').submit();
	}
}
function goBack(){
	location.href='<s:url value="/system/Role/list"/>';
}
$(function(){
	$('#editForm').validate();
	if($.trim($('#result').text())!=''){
		popupDiv('pop-div');
	}
});

</script>
<title><s:text name="system.title" /></title>
</head>
<body>
<s:include value="/common/up.jsp"></s:include>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td class="box">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td id="tag-over"><span id="tag-over">Role </span></td>
				<td class="tab3-line" width="90%">&nbsp;</td>
			</tr>
		</table>
		<s:form action="Role/save" namespace="/system" method="post" id="editForm" name="editForm">
		<s:hidden name="id"></s:hidden>
		<s:hidden name="menu" id="menu"></s:hidden>
		<table width="100%" border="0" cellpadding="3" cellspacing="1" class="margin">
			<tr>
				<td align="right" width="50%" class="tablecolour5">Role Name<font color="red">*</font>:</td>
				<td width="50%" class="tablecolour5"><s:textfield name="name" cssClass="input2 required" size="24" /></td>
			</tr>
			<tr>
				<td align="right" width="50%" class="tablecolour5">Description:</td>
				<td width="50%" class="tablecolour5"><s:textarea name="description" cssClass="input2" cssStyle="width:90%;height:120px;"/></td>
			</tr>
			 
			
		<tr>
			<td align="center" colspan="2" height="50" class="tablecolour5">
			<input type="button" class="btn1" value="Save"  onclick="doSubmit();"  /> 
			<input name="goback" type="button" class="btn1"
				value="Go Back" onclick="goBack()" /></td>
		</tr>
		</s:form>
		<tr>
				<td  colspan="2"  style="background-color: #fff;" >&nbsp;&nbsp;
				<script type="text/javascript">
 	  d = new dTree('d');
 	   d.config.useCheckBox = true;
 	   
 	  d.config.useStatusText = true;
 	  d.add(0,-1,'sytstem menu','javascript:init();');
 	  <%=request.getAttribute("treeData") %>
 	
 	 document.write(d);
 	    d.setCheckedNode('<s:property value="menu"/>');

 	  
 </script>
				</td>
			</tr>
		</table>
		</td>
	</tr>
</table>
<s:include value="/common/down.jsp"></s:include>
<div id='pop-div' style="width: 300px;" class="pop-box">  
  <s:include value="/common/confirm.jsp"></s:include>   
</div>

</body>
</html>